<template>
	<view>
		<view class="input-box">
		<view class="input-box-real flex">
			<text>支付宝账号</text>
			<u--input v-model="account" border="none" inputAlign='right'  placeholder="输入支付宝账号">
			</u--input>
		</view>
	</view>
	<view class="input-box">
		<view class="input-box-real flex">
			<text>支付宝姓名</text>
			<u--input v-model="zfbname" border="none" inputAlign='right'  placeholder="填写支付宝姓名">
			</u--input>
		</view>
	</view>
	<view class="submit-btn" @click="bindzfb">
		绑定
	</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				account:'',
				zfbname:''
			};
		},
		onLoad() {
			this.init()
		},
		methods:{
			init(){
				this.$api.post('/updateuserpay',{}).then(res=>{
					if(res.code == 1){
						this.account = res.data.alipay
						this.zfbname = res.data.alipay_name
					}
				})
			},
			bindzfb(){
				if(!this.account){
					this.$toast('请输入支付宝账号')
					return
				}
				if(!this.zfbname){
					this.$toast('请输入支付宝姓名')
					return
				}
				this.$api.post('/updateuserpay',{type:'update',alipay_name:this.zfbname,alipay:this.account}).then(res=>{
					if(res.code == 1){
						this.$toast(res.msg)
						setTimeout(()=>{
							this.$back()
						},1000)
					}
				})
			},
		}
	}
</script>

<style lang="scss">
.input-box {
		width: 90vw;
		margin: 50rpx auto;
		border-radius: 30rpx;
		background-color: #FBFBFE;
		.input-box-real{
			background-color: #fff;
			border-radius: 30rpx;
			align-items: center;
			justify-content: space-between;
			padding: 30rpx 50rpx;
		}
		.available{
			padding: 40rpx 30rpx;
			align-items: center;
			justify-content: space-between;
		}
	}
</style>
